<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/layui/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form" enctype="multipart/form-data">

    <input name="id" type="hidden" value="${account.id}">

    <div class="layui-form-item">
        <label class="layui-form-label required">请选择头像</label>
        <div class="layui-input-block">
            <img src="${account.headImg}" width="50" height="50">
            <input type="hidden" name="headImg" value="${account.headImg}">
            <button type="button" class="layui-btn" id="test1">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>

    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phoneNum" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="${account.phoneNum}" class="layui-input">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" lay-verify="required" value="${account.password}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">自媒体帐号</label>
        <div class="layui-input-block">
            <input type="text" name="userName" lay-verify="required" value="${account.userName}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">自媒体帐号的名字</label>
        <div class="layui-input-block">
            <input type="text" name="accountName" lay-verify="required" value="${account.accountName}" class="layui-input">
        </div>
    </div>
<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label required">所属平台</label>--%>
<%--        <div class="layui-input-block">--%>
<%--            <input type="text" name="platformId" lay-verify="required" value="${account.platform.name}" class="layui-input">--%>
<%--        </div>--%>
<%--    </div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label required">粉丝数量</label>
        <div class="layui-input-block">
            <input type="text" name="fansAmount" lay-verify="required" value="${account.fansAmount}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">订阅数量</label>
        <div class="layui-input-block">
            <input type="text" name="subsAmount" lay-verify="required" value="${account.subsAmount}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">访问量</label>
        <div class="layui-input-block">
            <input type="text" name="accountPv" value="${account.accountPv}" class="layui-input">
        </div>
    </div>
<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label required">帐号详情的url</label>--%>
<%--        <div class="layui-input-block">--%>
<%--            <input type="text" name="url" lay-verify="required" value="${account.url}" class="layui-input">--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label required">帐号详情图片</label>--%>
<%--        <div class="layui-input-block">--%>
<%--            <input type="text" name="detailImg" lay-verify="required" value="${account.detailImg}" class="layui-input">--%>
<%--        </div>--%>
<%--    </div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label required">帐号归属</label>
        <div class="layui-input-block">
            <select class="layui-select" name="owner">
                <option value="1" <c:if test="${owner.sex == '1'}">selected</c:if>>个人</option>
                <option value="2" <c:if test="${owner.sex == '2'}">selected</c:if>>平台</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>

</div>
<script src="/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form','upload','layer','element'], function () {
        var form = layui.form,
            layer = layui.layer,
            element = layui.element,
            upload = layui.upload,
            $ = layui.jquery;

        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,url: '/upload/' //上传接口
            ,done: function(res){
                // 刷新上一层页面
                parent.window.location.reload();
                layer.msg('修改成功');
            }
            ,error: function(){
                //请求异常回调
            }
        });


        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: '/resource/modify',
                type: 'post',
                data: JSON.stringify(data.field),
                contentType: 'application/json',
                dataType: 'json',
                success: function (result) {
                    if (result.code == '0') {
                        // 关闭弹出层
                        layer.close();
                        // 刷新上一层页面
                        parent.window.location.reload();
                    }
                }
            });

            return false;
        });

    });
</script>
</body>
</html>
